import tabbar from '../../utils/tabbar'
let user
Page({
  data: {
    active: 3,
    isLogin: true
  },

    /**
   * 初始化数据，判断登陆
   */
  initData() {
    user = wx.getStorageSync('user')
    console.log(typeof wx.getStorageSync('user'), user)
    if (typeof user != 'object') {
      this.setData({
        isLogin: false
      })
      // wx.navigateTo({
      //   url: '/pages/login/login'
      // })
      return
    }
    this.setData({
      user: user
    })
  },

  /**
   * 前往登陆页
   */
  toLogin() {
    wx.navigateTo({
      url: '/pages/login/login'
    })
  },

  onLoad: function (options) {
    this.initData()
  },

  /**
   * tabber改变
   */
  onTabbarChange(e) {
    tabbar.redirectTo(e.detail)
  },

  /**
   * 拨打电话
   */
  makePhoneCall() {
    wx.makePhoneCall({
      phoneNumber: '0351-12345678' //仅为示例，并非真实的电话号码
    })
  },

  /**
   * 跳转收获地址页
   */
  toAddress() {
    wx.navigateTo({
      url: '/pages/address/address'
    })
  },

  /**
   * 跳转个人信息页
   */
  toMyInfo() {
    wx.navigateTo({
      url: '/pages/myInfo/myInfo'
    })
  },

  /**
   * 跳转全部订单页
   */
  toOrderList() {
    wx.navigateTo({
      url: '/pages/orderList/orderList'
    })
  },

  /**
   * 跳转admin
   */
  toAdmin() {
    wx.navigateTo({
      url: '/pages/admin/orderList/orderList'
    })
  },

  toInvitate() {
    wx.navigateTo({
      url: '/pages/invitate/invitate',
    })
  },
})